﻿#include "filetrans.h"
#include "ui_filetrans.h"

FileTrans::FileTrans(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FileTrans)
{
    ui->setupUi(this);
    ui->progressBar->hide();
    ui->label_filename->setText("等待对方同意接收中...");
}

FileTrans::~FileTrans()
{
    delete ui;
}

FileTrans &FileTrans::getInstance()
{
    static FileTrans ft;
    return ft;
}

void FileTrans::setLableContent(int cmd,QString text)
{
    if(cmd==0)
    {
        ui->label_filename->setText("等待对方接收中...");
    }
    if(cmd==1)
    {
        ui->label_filename->setText("正在传输文件" +QString(text)+"中...");
    }
    if(cmd == 2)
    {
        ui->label_filename->setText("文件" +QString(text)+"传输完毕!");
    }
}

void FileTrans::setProgressMax(int val)
{
    ui->progressBar->setMaximum(val);
    ui->progressBar->show();
}

void FileTrans::setProgress(int val)
{
    ui->progressBar->setValue(val);
}
